<!DOCTYPE html>
<html lang="zh-Hans">
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="王诗翔" />



<meta name="description" content="该命令集可以非常方便地向远程主机/服务器上传文件、运行远程脚本、下载文件等。">
<meta property="og:type" content="article">
<meta property="og:title" content="Sync deploy 命令工具">
<meta property="og:url" content="https://shixiangwang.github.io/2018/01/31/sync-deploy-tools/index.html">
<meta property="og:site_name" content="Cloudberry">
<meta property="og:description" content="该命令集可以非常方便地向远程主机/服务器上传文件、运行远程脚本、下载文件等。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-02-07T15:36:54.917Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Sync deploy 命令工具">
<meta name="twitter:description" content="该命令集可以非常方便地向远程主机/服务器上传文件、运行远程脚本、下载文件等。">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="Cloudberry" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="../../../../css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>Sync deploy 命令工具 | Cloudberry</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>






</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">王诗翔</a></h1>
        </hgroup>

        
        <p class="header-subtitle">A site for writing life</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="false" />
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="../../../../index.html">主页</a></li>
                        
                            <li><a href="../../../../archives/">所有文章</a></li>
                        
                            <li><a href="../../../../tags/">标签云</a></li>
                        
                            <li><a href="../../../../about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:w_shixiang@163.com" title="Email"></a>
                            
                                <a class="fa GitHub" href="https://github.com/ShixiangWang" title="GitHub"></a>
                            
                                <a class="fa RSS" href="../../../../atom.xml" title="RSS"></a>
                            
                                <a class="fa 知乎" href="https://www.zhihu.com/people/wang-shi-xiang-65/activities" title="知乎"></a>
                            
                                <a class="fa 简书" href="https://www.jianshu.com/u/b6608e27dc74" title="简书"></a>
                            
                                <a class="fa Twitter" href="https://twitter.com/WangShxiang" title="Twitter"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Gist/">Gist</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Linux-shell/">Linux shell</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/OOP/">OOP</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/R/">R</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Rmarkdown/">Rmarkdown</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Rmd/">Rmd</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Rstudio/">Rstudio</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/bash-shell/">bash shell</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/fasta/">fasta</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/git/">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/github/">github</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/lapply/">lapply</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/markdown/">markdown</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/md/">md</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/sapply/">sapply</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/sed/">sed</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/shell笔记/">shell笔记</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/survival/">survival</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/survminer/">survminer</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/vapply/">vapply</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/写作/">写作</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/数据处理/">数据处理</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/文本处理/">文本处理</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/生存分析/">生存分析</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/生物信息学/">生物信息学</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/类/">类</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/迭代计算/">迭代计算</a></li></ul>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="http://www.ruanyifeng.com/blog/archives.html">阮一峰的网络日志</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://blog.fens.me/series-r/">R的极客理想系列</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://yihui.name/">谢益辉</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://www.huangshujia.me/">解螺旋的矿工</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://github.com/GuangchuangYu">GuangchuangYu</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://vip.biotrainee.com/">生信技能树</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">人该是自己生活的主宰，而不是别人手中的行货</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">王诗翔</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">王诗翔</a></h1>
            </hgroup>
            
            <p class="header-subtitle">A site for writing life</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="../../../../index.html">主页</a></li>
                
                    <li><a href="../../../../archives/">所有文章</a></li>
                
                    <li><a href="../../../../tags/">标签云</a></li>
                
                    <li><a href="../../../../about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:w_shixiang@163.com" title="Email"></a>
                            
                                <a class="fa GitHub" target="_blank" href="https://github.com/ShixiangWang" title="GitHub"></a>
                            
                                <a class="fa RSS" target="_blank" href="../../../../atom.xml" title="RSS"></a>
                            
                                <a class="fa 知乎" target="_blank" href="https://www.zhihu.com/people/wang-shi-xiang-65/activities" title="知乎"></a>
                            
                                <a class="fa 简书" target="_blank" href="https://www.jianshu.com/u/b6608e27dc74" title="简书"></a>
                            
                                <a class="fa Twitter" target="_blank" href="https://twitter.com/WangShxiang" title="Twitter"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我"/>
</nav>
      <div class="body-wrap"><article id="post-sync-deploy-tools" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="" class="article-date">
      <time datetime="2018-01-31T13:05:55.000Z" itemprop="datePublished">2018-01-31</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Sync deploy 命令工具
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="../../../../categories/开源工具/">开源工具</a>
    </div>


        
        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <p>该命令集可以非常方便地向远程主机/服务器上传文件、运行远程脚本、下载文件等。</p>
<div class="github-widget" data-repo="ShixiangWang/sync-deploy"></div>


<a id="more"></a>
<p><strong>目录</strong>：</p>
<ul>
<li><a href="https://github.com/ShixiangWang/sync-deploy#目的" target="_blank" rel="noopener">目的</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#下载与使用" target="_blank" rel="noopener">下载与使用</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#准备与配置" target="_blank" rel="noopener">准备与配置</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#命令说明" target="_blank" rel="noopener">命令说明</a><ul>
<li><a href="https://github.com/ShixiangWang/sync-deploy#sync-command" target="_blank" rel="noopener">sync-command</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#sync-upload" target="_blank" rel="noopener">sync-upload</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#sync-download" target="_blank" rel="noopener">sync-download</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#sync-run" target="_blank" rel="noopener">sync-run</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#sync-deploy" target="_blank" rel="noopener">sync-deploy</a></li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#sync-check" target="_blank" rel="noopener">sync-check</a></li>
</ul>
</li>
<li><a href="https://github.com/ShixiangWang/sync-deploy#计算操作实例" target="_blank" rel="noopener">计算操作实例</a></li>
</ul>
<h2 id="目的"><a href="#目的" class="headerlink" title="目的"></a>目的</h2><p>交互式地输入ssh、scp命令进行远端主机命令/脚本的执行、文件的上传与下载并不是很方便，有时候频繁地键入<code>hostname@ip</code>也是一件非常痛苦的事情。另外一方面，如果是向计算平台提交任务脚本，在远端文本命令窗口内修改作业参数以及调试运行脚本也是蛮不方便。所以仓库里脚本是为了能够比较方便地执行这一些任务。</p>
<p>命令集内置<code>ssh</code>、<code>scp</code>、<code>qsub</code>、<code>qstat</code>命令，分别用于运行远程脚本、命令、上传/下载文件、提交作业和查看作业状态。</p>
<h2 id="下载与使用"><a href="#下载与使用" class="headerlink" title="下载与使用"></a>下载与使用</h2><p><a href="https://github.com/ShixiangWang/sync-deploy/releases" target="_blank" rel="noopener">点击下载</a></p>
<p>或克隆：</p>
<figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">clone</span> <span class="title">https</span>://github.com/ShixiangWang/sync-deploy.git</span><br></pre></td></tr></table></figure>
<p>下载后执行<code>add_path.sh</code>脚本将命令添加到环境路径中，这样无论你处于什么目录都能使用。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd sync-deploy/src</span><br><span class="line">./add_path.sh</span><br></pre></td></tr></table></figure>
<p>除了<code>sync-command</code>命令没有选项，其他命令基本都有选项需要指定。</p>
<p><strong>对应地，除了<code>sync-command</code>其他命令都有<code>-h</code>选项，你可以获取帮助</strong>。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">sync-upload -h</span><br><span class="line">sync-download -h</span><br><span class="line">sync-run -h</span><br><span class="line">sync-deploy -h</span><br><span class="line">sync-check -h</span><br></pre></td></tr></table></figure>
<h2 id="准备与配置"><a href="#准备与配置" class="headerlink" title="准备与配置"></a>准备与配置</h2><p>首先在服务器端配置本地机器的公钥，以便于实现无密码文件传输。</p>
<p>参考文章<a href="https://www.liaohuqiu.net/cn/posts/ssh-keygen-abc/" target="_blank" rel="noopener">ssh-keygen基本用法</a>或其他资料生成公钥和私钥(搜索引擎可以找到一大堆这样的博文，我就不啰嗦了)。</p>
<p>将公钥<code>id_sra.pub</code>（本地机器.ssh子目录下）中文本内容拷贝到服务器.ssh子目录中的<code>authorized_keys</code>中，放在已有文本后面。如果该文件不存在则创建。</p>
<p>进行测试，如果不需要密码登录则成功。</p>
<p><strong>然后点击打开当前目录（src/）的<code>sync-setting</code>文件，将远程主机的host名与ip地址改为你自己的</strong>。</p>
<hr>
<p><strong>如果你想要在计算平台部署任务</strong>，请点击打开当前目录下的<code>qsub_header</code>文件填入PBS参数，设置可以参考<a href="https://github.com/ShixiangWang/mytoolkit/blob/master/hpc_info.md" target="_blank" rel="noopener">我整理的</a>或者百度上的其他资源，例如<a href="https://wenku.baidu.com/view/5ab820293169a4517723a3ec.html" target="_blank" rel="noopener">1</a>，<a href="https://wenku.baidu.com/view/14ef7c230722192e4536f6f8.html" target="_blank" rel="noopener">2</a>等。</p>
<p><strong>接着在当前目录的<code>commands</code>文件夹填入你要运行的命令。如果你想要运行其他脚本，请在该文件中调用执行</strong>。</p>
<h2 id="命令说明"><a href="#命令说明" class="headerlink" title="命令说明"></a>命令说明</h2><h3 id="sync-command"><a href="#sync-command" class="headerlink" title="sync-command"></a>sync-command</h3><p>这个命令最简单粗暴，直接在<code>sync-command</code>后接你想要在远端执行的命令。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> sync-command ls -l <span class="string">'~/test'</span></span></span><br><span class="line">总用量 0</span><br><span class="line">-rw-rw-r-- 1 liuxs liuxs  12 1月  30 19:20 job_id</span><br><span class="line">-rw-rw-r-- 1 liuxs liuxs  34 1月  30 19:20 result.txt</span><br><span class="line">-rw-rw-r-- 1 liuxs liuxs 110 1月  29 11:40 test.R</span><br><span class="line">-rwxrw-r-- 1 liuxs liuxs 240 1月  30 19:20 work.sh</span><br></pre></td></tr></table></figure>
<p><strong>需要注意的是如果是想使用类似<code>~</code>这种映射到某个路径的符号，需要添加引号，不然它会被解析为本地地址，那当然会出问题的</strong></p>
<h3 id="sync-upload"><a href="#sync-upload" class="headerlink" title="sync-upload"></a>sync-upload</h3><p>上传文件到远程主机。</p>
<p>用法：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Usage: sync-upload -n local_files -d 'destdir'</span><br></pre></td></tr></table></figure>
<p><code>-n</code>选项后接你要上传的（本地机器）文件/目录路径，<code>-d</code>选项接远程主机上的目录路径。</p>
<p>用法示例：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">==&gt; examples:</span><br><span class="line">              sync-upload -n work.sh -d /public/home/liuxs/test</span><br><span class="line">         or</span><br><span class="line">              sync-upload -n work.sh -d '~/test'</span><br></pre></td></tr></table></figure>
<p>同样注意使用<code>~</code>时需要加引号。</p>
<p><strong>重点注意不支持-n与-d倒过来写，也就是选项是有顺序的</strong>，为什么如此的原因是为了使<code>-n</code>选项后能够接大于1个的路径参数，命令脚本内部利用了<code>-n</code>和<code>-d</code>的位置特点运用正则表达式抓取所有路径名，你可以利用该命令同时上传不止一个文件/目录（也算是有得有失吧）。</p>
<h3 id="sync-download"><a href="#sync-download" class="headerlink" title="sync-download"></a>sync-download</h3><p>从远程主机下载文件到本地机器。</p>
<p>用法：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Usage: sync-download -n 'remote_files' -d localdir</span><br></pre></td></tr></table></figure>
<p>这个命令的使用基本和<code>sync-upload</code>一致。</p>
<p>用法示例：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">==&gt; examples:</span><br><span class="line">              sync-download -n '~/test/*' -d ./test</span><br><span class="line">         or</span><br><span class="line">              sync-download -n /public/home/liuxs/test/* -d ./test</span><br></pre></td></tr></table></figure>
<p><strong>同样地，不支持<code>-n</code>与<code>-d</code>选项顺序反着写。</strong></p>
<h3 id="sync-run"><a href="#sync-run" class="headerlink" title="sync-run"></a>sync-run</h3><p>提交远程主机的作业，内置<code>qsub</code>命令向计算平台提交任务脚本。如果只是想要运行远程脚本或命令，请查看<code>sync-command</code>命令。</p>
<p>用法：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sync-run -f work_script</span><br></pre></td></tr></table></figure>
<p><code>-f</code>选项后接你要运行的<strong>一个</strong>脚本（需要指定脚本的路径哈）。</p>
<p>用法示例：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sync-run -f /home/wsx/work.sh</span><br></pre></td></tr></table></figure>
<h2 id="sync-deploy"><a href="#sync-deploy" class="headerlink" title="sync-deploy"></a>sync-deploy</h2><p>上传文件、提交作业一气呵成。</p>
<p>该命令内置调用<code>sync-upload</code>和<code>sync-run</code>这两个命令，以及其他几个脚本。在进行相关配置后，它可以根据<code>qsub_header</code>和<code>commands</code>两个文本自动生成作业脚本<code>work.sh</code>，上传指定文档（<code>work.sh</code>不指定也会上传），然后提交到任务节点进行运算。</p>
<p>用法：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Usage: sync-deploy -n local_files -d 'destdir'</span><br></pre></td></tr></table></figure>
<p>同样注意<code>~</code>的使用问题，另外，如果你只部署运行<code>work.sh</code>文档，那么请在<code>-n</code>选项后加<code>work.sh</code>，（因为<code>-n</code>选项后不加内容会报错）虽然该文本会被上传两次，但不会影响使用。</p>
<p>一个实例如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> sync-deploy -n work.sh -d <span class="string">'~/test'</span></span></span><br><span class="line">==&gt; command used: scp -pr -P 22 work.sh /home/wsx/working/sync-deploy/src/work.sh liuxs@10.15.22.110:~/test</span><br><span class="line">==&gt;</span><br><span class="line">work.sh                                                                                                         100%  240     0.2KB/s   00:00</span><br><span class="line">work.sh                                                                                                         100%  240     0.2KB/s   00:00</span><br><span class="line">==&gt; Files upload successfully.</span><br><span class="line"></span><br><span class="line">==&gt; run as batch mode.......</span><br><span class="line">job_id file locate at ~/test/job_id , id is</span><br><span class="line">87728.node1</span><br><span class="line">==&gt;</span><br><span class="line">==&gt; The work deploy successfully.</span><br></pre></td></tr></table></figure>
<h3 id="sync-check"><a href="#sync-check" class="headerlink" title="sync-check"></a>sync-check</h3><p>用来查看作业状态。</p>
<p>用法：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Usage: sync-deploy -n id</span><br></pre></td></tr></table></figure>
<p>如果指定<code>-n</code>选项加上作业号，会查询指定的作业状态，如果不指定，会查看所有的作业状态。</p>
<p>任务部署后会返回作业号，刚提交了两个作业，我们来查一查。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> sync-check -n 87730</span></span><br><span class="line">Job ID                    Name             User            Time Use S Queue</span><br><span class="line">------------------------- ---------------- --------------- -------- - -----</span><br><span class="line">87730.node1                work.sh          liuxs           00:00:00 C normal_3</span><br><span class="line"></span><br><span class="line"><span class="meta">$</span><span class="bash"> sync-check -n 87730.node1</span></span><br><span class="line">Job ID                    Name             User            Time Use S Queue</span><br><span class="line">------------------------- ---------------- --------------- -------- - -----</span><br><span class="line">87730.node1                work.sh          liuxs           00:00:00 C normal_3</span><br><span class="line"></span><br><span class="line"><span class="meta">$</span><span class="bash"> sync-check</span></span><br><span class="line">Job ID                    Name             User            Time Use S Queue</span><br><span class="line">------------------------- ---------------- --------------- -------- - -----</span><br><span class="line">87729.node1                work.sh          liuxs           00:00:00 C normal_3</span><br><span class="line">87730.node1                work.sh          liuxs           00:00:00 C normal_3</span><br></pre></td></tr></table></figure>
<h2 id="计算操作实例"><a href="#计算操作实例" class="headerlink" title="计算操作实例"></a>计算操作实例</h2><p>我们来通过一个完整的实例来了解这些命令。</p>
<p><strong>我们的任务是</strong>利用远程的计算平台运行一些shell命令，执行一个R脚本。</p>
<p>该R脚本位于<code>src/</code>的<code>test</code>目录下，这个脚本我们可以看做我们日常工作运行的主脚本。</p>
<p>我们需要准备什么呢？</p>
<p>只需要正确填写<code>qsub_header</code>与<code>commands</code>文档即可。</p>
<p>我们先看看<code>qsub_header</code>的内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">PBS -l nodes=1:ppn=10</span></span><br><span class="line"><span class="meta">#</span><span class="bash">PBS -S /bin/bash</span></span><br><span class="line"><span class="meta">#</span><span class="bash">PBS -j oe</span></span><br><span class="line"><span class="meta">#</span><span class="bash">PBS -q normal_3</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> Please <span class="built_in">set</span> PBS arguments above</span></span><br></pre></td></tr></table></figure>
<p>上述就是一些PBS选项和参数，按你自己的需求和正确写法填写即可。这里测试我就简单地设定了节点与队列。具体参数你可以百度或者参考说明文档前面提供的信息。</p>
<p>再瞧瞧<code>commands</code>文档：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> This job<span class="string">'s working directory</span></span></span><br><span class="line">cd ~/test</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> Following are commands</span></span><br><span class="line">sleep 20</span><br><span class="line">echo "Thi mission is run successfully!!" &gt; ~/test/result.txt</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> call Rscripts</span></span><br><span class="line">Rscript ~/test/test.R &gt; ~/test/result2.txt</span><br></pre></td></tr></table></figure>
<p>这个文档可能是我们工作主要需要修改的地方，这里我们用<code>cd</code>命令设定（作业的）工作目录，为避免任务结束太快，调用<code>sleep</code>命令让机器睡几秒，然后调用<code>echo</code>将一些文字结果传入一个结果文件，最后调用一个R脚本，并将结果传入另一个文件。</p>
<p>R脚本的内容也非常简单,就是输入几行文本：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">print("==&gt;")</span><br><span class="line">print("==&gt; Hello world!!!!!!!!")</span><br><span class="line">print("==&gt; ")</span><br></pre></td></tr></table></figure>
<p>为避免程序找不到或者找错文件，我们最好指定文件所在的全部路径。</p>
<p><strong>让我们开始跑命令吧～</strong></p>
<p>任务方案很简单，我们将<code>test.R</code>上传到远程主机的工作目录下，注意，<code>work.sh</code>也会自动生成并上传，它的内容就是<code>qsub_header</code>与<code>commands</code>的结合体。然后执行<code>work.sh</code>文本，然后将输出结果传回来。</p>
<p>上传与运行可以利用<code>sync-deploy</code>命令一步搞定：<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 利用add_path.sh将命令加入环境路径后，我们可以利用tab补全查找命令</span></span><br><span class="line">wsx@Desktop-berry:~$ sync-</span><br><span class="line">sync-check     sync-command   sync-deploy    sync-download  sync-run       sync-upload</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 利用sync-command查看目标路径情况</span></span><br><span class="line">wsx@Desktop-berry:~$ sync-command "ls -al  ~/test"</span><br><span class="line">总用量 8</span><br><span class="line">drwxrwxr-x  2 liuxs liuxs 4096 1月  30 23:52 .</span><br><span class="line">drwx------ 10 liuxs liuxs 4096 1月  30 22:51 ..</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 部署任务到远程</span></span><br><span class="line"></span><br><span class="line">wsx@Desktop-berry:~$ sync-deploy -n ~/working/sync-deploy/src/test/test.R -d '~/test/'</span><br><span class="line">==&gt; command used: scp -pr -P 22 /home/wsx/working/sync-deploy/src/test/test.R /home/wsx/working/sync-deploy/src/work.sh liuxs@10.15.22.110:~/test/</span><br><span class="line">==&gt;</span><br><span class="line">test.R                                                                                                          100%   60     0.1KB/s   00:00</span><br><span class="line">work.sh                                                                                                         100%  300     0.3KB/s   00:00</span><br><span class="line">==&gt; Files upload successfully.</span><br><span class="line"></span><br><span class="line">==&gt; run as batch mode.......</span><br><span class="line">job_id file locate at ~/test/job_id , id is</span><br><span class="line">87732.node1</span><br><span class="line">==&gt;</span><br><span class="line">==&gt; The work deploy successfully.</span><br></pre></td></tr></table></figure></p>
<p>可以看到任务成功部署并返回了<code>job id</code>，利用<code>sync-check</code>命令查询</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">wsx@Desktop-berry:~$ sync-check 87732</span><br><span class="line">Job ID                    Name             User            Time Use S Queue</span><br><span class="line">------------------------- ---------------- --------------- -------- - -----</span><br><span class="line">87732.node1                work.sh          liuxs           00:00:00 C normal_3</span><br></pre></td></tr></table></figure>
<p>因为任务时间不长，很快就搞定了，已经出现了<code>C</code>标志（完成）。</p>
<p>我们查看一下远程目录情况：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">wsx@Desktop-berry:~$ sync-command ls '~/test'</span><br><span class="line">job_id</span><br><span class="line">result2.txt</span><br><span class="line">result.txt</span><br><span class="line">test.R</span><br><span class="line">work.sh</span><br></pre></td></tr></table></figure>
<p><code>job_id</code>文件是用来保存作业号信息的，就是前面输出的<code>87732.node1</code>。其他不用解释了。</p>
<p>最后一步，将需要的结果下载回本地。</p>
<p>我们创建一个临时目录单独存储，然后查看文件内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">wsx@Desktop-berry:~$ mkdir test</span><br><span class="line">wsx@Desktop-berry:~$ sync-download -n "~/test/*" -d ~/test</span><br><span class="line">==&gt; command used: scp -pr -P 22 liuxs@10.15.22.110:~/test/* /home/wsx/test</span><br><span class="line">==&gt;</span><br><span class="line">job_id                                                                                                          100%   12     0.0KB/s   00:00</span><br><span class="line">result2.txt                                                                                                     100%   51     0.1KB/s   00:00</span><br><span class="line">result.txt                                                                                                      100%   34     0.0KB/s   00:00</span><br><span class="line">test.R                                                                                                          100%   60     0.1KB/s   00:00</span><br><span class="line">work.sh                                                                                                         100%  300     0.3KB/s   00:00</span><br><span class="line">==&gt; Files download successfully.</span><br><span class="line"></span><br><span class="line">wsx@Desktop-berry:~$ cd test/</span><br><span class="line">wsx@Desktop-berry:~/test$ ls</span><br><span class="line">job_id  result2.txt  result.txt  test.R  work.sh</span><br><span class="line">wsx@Desktop-berry:~/test$ cat result.txt</span><br><span class="line">Thi mission is run successfully!!</span><br><span class="line">wsx@Desktop-berry:~/test$ cat result2.txt</span><br><span class="line">[1] "==&gt;"</span><br><span class="line">[1] "==&gt; Hello world!!!!!!!!"</span><br><span class="line">[1] "==&gt; "</span><br></pre></td></tr></table></figure>
<p><strong>任务完成！</strong></p>
<h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>有问题欢迎<a href="https://github.com/ShixiangWang/sync-deploy/issues" target="_blank" rel="noopener">提交issue</a>进行讨论。</p>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="">Sync deploy 命令工具</a></p>
        <!-- modify author information
        <p><span>文章作者:</span><a href="/" title="回到主页">王诗翔</a></p>
        -->
        <p><span>文章作者:</span>王诗翔</p>
        <p><span>发布时间:</span>2018-01-31, 21:05:55</p>
        <p><span>最后更新:</span>2018-02-07, 23:36:54</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="" title="Sync deploy 命令工具">https://shixiangwang.github.io/2018/01/31/sync-deploy-tools/</a>
            <span class="copy-path" data-clipboard-text="原文: https://shixiangwang.github.io/2018/01/31/sync-deploy-tools/　　作者: 王诗翔" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="../sed-how-to-filter-rows-before-using-command/">
                    sed如何在执行命令前过滤特定文本行
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="../../../../2017/12/25/sed-and-gawk/">
                    初识sed与awk
                </a>
            </div>
        
    </nav>


  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#目的"><span class="toc-number">1.</span> <span class="toc-text">目的</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#下载与使用"><span class="toc-number">2.</span> <span class="toc-text">下载与使用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#准备与配置"><span class="toc-number">3.</span> <span class="toc-text">准备与配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#命令说明"><span class="toc-number">4.</span> <span class="toc-text">命令说明</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#sync-command"><span class="toc-number">4.1.</span> <span class="toc-text">sync-command</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#sync-upload"><span class="toc-number">4.2.</span> <span class="toc-text">sync-upload</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#sync-download"><span class="toc-number">4.3.</span> <span class="toc-text">sync-download</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#sync-run"><span class="toc-number">4.4.</span> <span class="toc-text">sync-run</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#sync-deploy"><span class="toc-number">5.</span> <span class="toc-text">sync-deploy</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#sync-check"><span class="toc-number">5.1.</span> <span class="toc-text">sync-check</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#计算操作实例"><span class="toc-number">6.</span> <span class="toc-text">计算操作实例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#问题"><span class="toc-number">7.</span> <span class="toc-text">问题</span></a></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></i></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"Sync deploy 命令工具　| Cloudberry　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
        <section id="comments">
    <style> aside.comment-bar { margin: auto 30px; }</style>
    <div id="disqus_thread"></div>
    <script>
        var disqus_config = function(){
            this.page.url = 'https://shixiangwang.github.io/2018/01/31/sync-deploy-tools/';
            this.page.identifier = '2018/01/31/sync-deploy-tools/';
        };
        var loadComment = function(){
            var d = document, s = d.createElement('script');
            s.src = '//Cloudberry.disqus.com/embed.js';
            s.setAttribute('data-timestamp', +new Date());
            (d.head || d.body).appendChild(s);
        }
    </script>
    
    <script> loadComment(); </script>

</section>


    




    <div class="scroll" id="post-nav-button">
        
            <a href="../sed-how-to-filter-rows-before-using-command/" title="上一篇: sed如何在执行命令前过滤特定文本行">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="../../../../2017/12/25/sed-and-gawk/" title="下一篇: 初识sed与awk">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="../../../02/26/python-basics/">两天研习Python基础</a></li><li class="post-list-item"><a class="post-list-link" href="../../../02/12/how-to-create-an-independent-figpath/">为markdown博文创建独立图片路径</a></li><li class="post-list-item"><a class="post-list-link" href="../../../02/10/easy-sapply-apply-vapply/">简单理解lapply,sapply,vapply</a></li><li class="post-list-item"><a class="post-list-link" href="../../../02/07/how-to-do-group-survival-analysis/">怎么对连续变量分组并进行生存分析</a></li><li class="post-list-item"><a class="post-list-link" href="../../../02/06/how-to-write-rmd-documents-in-hexo-system/">怎么在hexo博客系统中用Rmarkdown写文章</a></li><li class="post-list-item"><a class="post-list-link" href="../sed-how-to-filter-rows-before-using-command/">sed如何在执行命令前过滤特定文本行</a></li><li class="post-list-item"><a class="post-list-link" href="">Sync deploy 命令工具</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/12/25/sed-and-gawk/">初识sed与awk</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/12/08/Git-basic-operation/">学习git</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/11/29/shell-create-text-menu-and-window/">使用shell创建文本菜单和窗口部件</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/11/26/shell-create-function/">创建和使用shell函数</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/09/20/OOPinR/">R-面向对象编程</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/09/15/Class-in-R/">R中的属性与类</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/09/04/control_shell/">控制脚本</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/09/03/Linux-data-analysis-tools/">Linux数据处理命令工具</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/08/21/shell-show-data/">Linux脚本编程——呈现数据</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/08/19/working-with-user-input/">Shell脚本之处理用户输入</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/08/11/structural-command-of-shell/">Linux结构化命令</a></li><li class="post-list-item"><a class="post-list-link" href="../../../../2017/08/11/basic-shell/">构建基本shell脚本</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2017-2018 王诗翔
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="本站到访数"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="本页阅读量"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
    <script src="../../../../js/GithubRepoWidget.js"></script>

<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 2;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





    <script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
             github: ".github-widget a", 
            
             post: ".article-entry a[href], .copyright a[href]", 
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

    <script>
        var originTitle = document.title;
        var titleTime;
        document.addEventListener("visibilitychange", function() {
            if (document.hidden) {
                document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
                clearTimeout(titleTime);
            }
            else {
                document.title = "(*´∇｀*) 被你发现啦~ " + originTitle;
                titleTime = setTimeout(function() {
                    document.title = originTitle;
                }, 2000);
            }
        })
    </script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>